#include "headfiles.h"

using namespace std;

int main(int argc, char **argv) {
	if (argc != 2) {
		cout << "Usage: " << argv[0] << " filename" << endl;
		return 0;
	}

	char file_name[255];
	sprintf(file_name, "%s", argv[1]);

	NODE *root;
	NODE **node_list;
	int node_num;
	
	// create binary tree and get node list
	root = createBinaryTreeAll(file_name, node_list, node_num);

	// print the binary tree
	printBinaryTree(root);

	// Get the next node of each node
	cout << "Node num = " << node_num << endl;
	int i;
	for (i = 0; i < node_num; i++) {
		NODE *next = findNextNode(node_list[i]);
		cout << "The next node of node: " << node_list[i]->i << ": ";
		if (next == NULL) {
			cout << "NULL!" << endl;
		}
		else {
			cout << next->i << "." << endl;
		}
	}

	destroyTree(root);

	return 0;
}

